package com.liugui;

/**
 * @ClassName: RunnableDemo
 * @Author: liugui
 * @Date: 2021-05-19 11:15
 **/
public class RunnableDemo {
    public static void main(String[] args) {
        MyThread myThread1 = new MyThread("测试线程1");
        MyThread myThread2 = new MyThread("测试线程2");
        Thread t1 = new Thread(myThread1);
        Thread t2 = new Thread(myThread2);

        t1.start();
        t2.start();
    }
}

class MyThread implements Runnable{

    private String strName;

    public MyThread(String strName) {
        this.strName = strName;
    }

    public MyThread() {
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(this.strName + "执行第 " + i + " 次");
        }
    }
}
